home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / languages / lockwindow.lha / LockWindow / LockWindow.mod < prev   
Encoding:
Text File  |  1995-02-17  |  7.4 KB  |  290 lines

  1. (*
  2. (****** LockWindow/--AMOK-Header-- ******************************************
  3.  
  4. :Program.    LockWindow.mod
  5. :Author.     Albert Weinert [awn], Kai Bolai [kai],
  6. :Author.     hartmut Goebel [hG], Oliver Knorr [olk]
  7. :Version.    $VER: LockWindow.mod 1.4 (16.2.95)
  8. :Copyright.  Freeware
  9. :Language.   Oberon
  10. :Translator. Amiga Oberon 3.11
  11. :Contents.   Procedures for setting a "busy"-mousepointer and for "locking"
  12. :Contents.   windows, so all user input is blocked.
  13.  
  14. *****************************************************************************
  15. *
  16. *)
  17. *)
  18.  
  19. MODULE LockWindow;
  20.  
  21. (****** LockWindow/--background-- *******************************************
  22. *
  23. *       The "User Interface Style Guide" (UISG) suggests that the user
  24. *       should be informed when a window can temporary not accept any
  25. *       input. The most simple possibility is to use a "busy" mouse-pointer.
  26. *       A "busy"-pointer has a special look defined in the UISG.
  27. *
  28. *       This module gives you one set of procedures to set and remove
  29. *       only the busy-pointer and another to both change the mouse-pointer
  30. *       and block all user input by opening an invisible Intuition
  31. *       Requester.
  32. *
  33. *****************************************************************************
  34. *
  35. *)
  36.  
  37. (****** LockWindow/--history-- **********************************************
  38. *
  39. *   V1.4   : 16-Feb-1995 [olk]
  40. *       UnlockWindow() uses ClearWaitPointer() instead of I.ClearPointer().
  41. *       All procedures now check for NIL-pointers.
  42. *       Documentation revised and translated to English.
  43. *
  44. *   V1.3   : 24-Sep-1993 [awn]
  45. *       New documentation in AutoDoc-Format.
  46. *
  47. *   V1.2   : 19-Sep-1993 [hG] (based on V1.1)
  48. *       LockWindow() now uses SYSTEM.ALLOCATE().
  49. *       Under V39+ the default BusyPointer is used.
  50. *       Now works with garbage collector.
  51. *       Needs V39 Interfaces.
  52. *
  53. *   V1.1.1 : ??-???-???? [kai]
  54. *       Under V39+ the default BusyPointer is used.
  55. *
  56. *   V1.1   : 19-Aug-1992 [awn]
  57. *       Mouse-pointer setting has been moved to separate Procedures.
  58. *
  59. *   V1.0   : 02-Aug-1992 [awn]
  60. *       First working version.
  61. *
  62. *****************************************************************************
  63. *
  64. *)
  65.  
  66.  
  67. IMPORT
  68.   I * := Intuition,
  69.   u := Utility,
  70.   SYSTEM;
  71.  
  72. TYPE
  73.   sprite = ARRAY 36 OF INTEGER;
  74.  
  75. (* $DataChip+ *)
  76. CONST
  77.   waitPointer = sprite(
  78.     00000H, 00000U,
  79.     00400H, 007C0U,
  80.     00000H, 007C0U,
  81.     00100H, 00380U,
  82.     00000H, 007E0U,
  83.     007C0H, 01FF8U,
  84.     01FF0H, 03FECU,
  85.     03FF8H, 07FDEU,
  86.     03FF8H, 07FBEU,
  87.     07FFCH, 0FF7FU,
  88.     07EFCH, 0FFFFU,
  89.     07FFCH, 0FFFFU,
  90.     03FF8H, 07FFEU,
  91.     03FF8H, 07FFEU,
  92.     01FF0H, 03FFCU,
  93.     007C0H, 01FF8U,
  94.     00000H, 007E0U,
  95.     00000H, 00000H);             (* reserved, must be NULL *)
  96. (* $DataChip- *)
  97.  
  98.  
  99. (****** LockWindow/SetWaitPointer *******************************************
  100. *
  101. *   NAME
  102. *       SetWaitPointer -- set a window's mouse-pointer to "busy"-state
  103. *
  104. *   SYNOPSIS
  105. *       SetWaitPointer (window: I.WindowPtr)
  106. *
  107. *   FUNCTION
  108. *       Changes the look of an Intuition Window's mouse-pointer to "busy".
  109. *
  110. *   INPUTS
  111. *       window = Intuition Window that shall get a "busy" mouse-pointer.
  112. *
  113. *   NOTES
  114. *       Running und Intuition V39 or higher, the busy-pointer defined in
  115. *       preferences will be used. Under ealier versions, the busy-pointer
  116. *       suggested by the UISG (a clock) will be used.
  117. *
  118. *       This Procedure only changes the mouse-pointer look, input is *not*
  119. *       blocked by this.
  120. *
  121. *   SEE ALSO
  122. *       ClearWaitPointer(), LockWindow()
  123. *
  124. *****************************************************************************
  125. *
  126. *)
  127.  
  128.   PROCEDURE SetWaitPointer * (window: I.WindowPtr);
  129.  
  130.     BEGIN
  131.       IF window # NIL THEN
  132.         IF I.int.libNode.version >= 39 THEN
  133.           I.SetWindowPointer(window, I.waBusyPointer,  I.LTRUE,
  134.                                      I.waPointerDelay, I.LTRUE,
  135.                                      u.done, 0)
  136.         ELSE
  137.           I.SetPointer(window, waitPointer, 16, 16, -6, 0)
  138.         END
  139.       END
  140.     END SetWaitPointer;
  141.  
  142.  
  143. (****** LockWindow/ClearWaitPointer *****************************************
  144. *
  145. *   NAME
  146. *       ClearWaitPointer -- set a window's mouse-pointer to "normal"-state
  147. *
  148. *   SYNOPSIS
  149. *       ClearWaitPointer (window: I.WindowPtr)
  150. *
  151. *   FUNCTION
  152. *       Removes the "busy" mouse-pointer from a window.
  153. *
  154. *   INPUTS
  155. *       window = Intuition Window that shall get a "normal" mouse-pointer,
  156. *                as defined in preferences.
  157. *
  158. *   NOTES
  159. *
  160. *   SEE ALSO
  161. *       SetWaitPointer()
  162. *
  163. *****************************************************************************
  164. *
  165. *)
  166.  
  167.   PROCEDURE ClearWaitPointer * (window: I.WindowPtr);
  168.  
  169.     BEGIN
  170.       IF window # NIL THEN
  171.         IF I.int.libNode.version >= 39 THEN I.SetWindowPointer(window, u.done, 0)
  172.                                        ELSE I.ClearPointer(window) END
  173.       END
  174.     END ClearWaitPointer;
  175.  
  176.  
  177. (****** LockWindow/LockWindow ***********************************************
  178. *
  179. *   NAME
  180. *       LockWindow -- lock an Intuition Window
  181. *
  182. *   SYNOPSIS
  183. *       LockWindow (window: I.WindowPtr): I.RequesterPtr
  184. *
  185. *   FUNCTION
  186. *       Locks an Intuition Window by opening an invisible Requester,
  187. *       so all user input is completely blocked. To give the user a visible
  188. *       hint for this, the mouse-pointer is set to "busy"-look with
  189. *       SetWaitPointer().
  190. *
  191. *   INPUTS
  192. *       window = Intuition Window that shall be locked
  193. *
  194. *   RESULTS
  195. *       Pointer to the invisible Intuition Requester. Use it to
  196. *       unlock the Window again.
  197. *
  198. *   EXAMPLE
  199. *
  200. *       MODULE Test.
  201. *
  202. *       IMPORT lw := LockWindow,
  203. *              I  := Intuition,
  204. *
  205. *       VAR req: I.RequesterPtr;
  206. *           win: I.WindowPtr;
  207. *
  208. *       BEGIN
  209. *         [......]
  210. *         req := lw.LockWindow( win );
  211. *         [......]
  212. *         lw.UnlockWindow( req );
  213. *       END Test.
  214. *
  215. *   NOTES
  216. *
  217. *   BUGS
  218. *       The size-gadget of a locked window (if it has one) can still be
  219. *       used. So please mind that the user might have changed the window
  220. *       size while it was locked.
  221. *
  222. *   SEE ALSO
  223. *       UnlockWindow(), SetWaitPointer(), Intuition/Request()
  224. *
  225. *****************************************************************************
  226. *
  227. *)
  228.  
  229.   PROCEDURE LockWindow * (window: I.WindowPtr): I.RequesterPtr;
  230.  
  231.     VAR
  232.       req: I.RequesterPtr;
  233.  
  234.     BEGIN
  235.       IF window = NIL THEN RETURN NIL END;
  236.       SYSTEM.ALLOCATE(req);
  237.       IF (req # NIL) THEN
  238.         IF I.Request(req,window) THEN
  239.           SetWaitPointer(window)
  240.         ELSE
  241.           (* $IFNOT GarbageCollector *)
  242.             DISPOSE(req);
  243.           (* $END *)
  244.             req := NIL
  245.         END
  246.       END;
  247.       RETURN req
  248.     END LockWindow;
  249.  
  250.  
  251. (****** LockWindow/UnlockWindow *********************************************
  252. *
  253. *   NAME
  254. *       UnlockWindow -- unlock an Intuition Window
  255. *
  256. *   SYNOPSIS
  257. *       UnlockWindow (VAR req: I.RequesterPtr)
  258. *
  259. *   FUNCTION
  260. *       Unlocks a window that has been locked with LockWindow() and
  261. *       restores the normal mouse-pointer.
  262. *
  263. *   INPUTS
  264. *       req = Pointer to the Requester returned by LockWindow().
  265. *
  266. *   NOTES
  267. *
  268. *   SEE ALSO
  269. *       LockWindow(), ClearWaitPointer()
  270. *
  271. *****************************************************************************
  272. *
  273. *)
  274.  
  275.   PROCEDURE UnlockWindow * (VAR req: I.RequesterPtr);
  276.  
  277.     BEGIN
  278.       IF req # NIL THEN
  279.         ClearWaitPointer(req.rWindow);
  280.         I.EndRequest(req,req.rWindow);
  281.         (* $IFNOT GarbageCollector *)
  282.           DISPOSE(req);
  283.         (* $END *)
  284.         req := NIL
  285.       END
  286.     END UnlockWindow;
  287.  
  288.  
  289. END LockWindow.
  290.